<!DOCTYPE html>
<html lang="zh-cn">
<head>
<title>{$cp.comment_name} - {$cp.name}</title>
<meta name="renderer" content="webkit">
<meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="no-cache, no-store, must-revalidate" http-equiv="Cache-Control" />
<meta content="no-cache" http-equiv="Pragma" />
<meta content="0" http-equiv="Expires" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="/static/css/zui.min.css" />
</head>
<body>

<script type="text/javascript" src="{$_lang.company_path}/admin/template/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/js/zui.js"></script>
<script type="text/javascript" src="{$_lang.company_path}/admin/template/js/common.js"></script>

<style type="text/css">
/*新闻详情页*/
.new-detail{
	max-width:640px;
	margin:0 auto;
}
.new-detail>i{
    font-size: 24px;
    color: #13a09e;
    position: fixed;
	z-index:10;
    top: 20px;
    left: 20px;
}
.new-detail>.new-content{
	padding:10px;
}
.new-detail>.new-content>img{
    max-width:100%;
}
.new-detail .new-title{
	position:fixed;
	top:0;
	left:0;
	background:#fff;
	width:100%;
    height:60px;
	font-size:16px;
	line-height:65px;
	overflow:hidden;
	text-align:center;
	padding:0 10px 0 40px;
	border-bottom:1px solid #eee
}
/*返回按钮*/
.back-fg{
    position: fixed;
    z-index: 20;
    bottom: 0;
    left: 0;
    height: 60px;
    width: 100%;
    background: rgba(255,255,255,0.5);
}
.back-go{
    display: inline-block;
    position: fixed;
    z-index: 30;
    bottom: 10px;
    left: 30%;
    height:40px;
    text-align: center;
    line-height: 40px;
    font-size: 16px;
    width: 40%;
    background: #2db2b0;
    color: #ffffff;
    border-radius: 4px;
    border: 2px solid #13a09e;
}
/*评论表单*/
form.article_comment{
	padding:10px;
	border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    background: #eee;
}
form.article_comment input[type=text],form.article_comment textarea{
	border:1px solid #555;padding:4px;border-radius:4px;
}
/* 留言 */
#comment{
	padding:10px;
}
#loading{
	padding:10px;text-align:center;display:none;
}
</style>


	<!--新闻详情页 begin-->
	<div class="new-detail">
		<i class="icon icon-angle-left" onClick="javascript:window.location.href='/company/?cid={$cp.c_id}'"></i>
		<div class="new-title">{$cp.comment_name} - {$cp.name}</div>
		<div style="height:70px"></div>
		
		<script type="text/javascript" src="/static/js/jquery.form.js"></script>
		<script type="text/javascript" src="{$_lang.company_path}/admin/template/js/jquery.form.submit.js"></script>
		<form action="/comment/?act=comment" id="form" method="post" enctype="multipart/form-data" class="article_comment">
			<p><input type="text" name="name" placeholder="请输入您的姓名">
			<p><input type="text" name="phone" placeholder="请输入您的手机号">
			<p><textarea name="comment" id="" cols="30" rows="5" placeholder="请输入您的留言内容"></textarea>
			<input type="hidden" name="cid" value="{$cp.c_id}">
			<input type="hidden" name="new_id" value="0">
			<div>
			<input type="button" class="btn btn-primary" value="确认提交" id="sub_btn" onClick="javascript:ajaxFormSubmit('form','提交');">			
			<span id="wrong_text"></span>
			</div>
			<div style="clear:both"></div>
		</form>
		
		<div id="comment">		
 		</div>
		<div id="loading"><img src="/static/images/s_loading.gif"/></div>
		
	</div>
	<script>
        var page = 1;
        var cid = '{$cp.c_id}';
        $(function(){
            list_comments();
            $('.new-content').scroll(function(){
                var scrollTop = $(this).scrollTop();
                var divHeight = $(this).height();
                var scrollHeight = $(this)[0].scrollHeight;
                if(scrollTop + divHeight +30>= scrollHeight){
                    list_comments();
                }
            });
        });
		var flag = true;
		var flag_one = true;
        function list_comments(){
            if(flag && flag_one){
                flag_one = false;
				$("#loading").show();
                $.post('/comment/?act=ajaxComment',{
                    'cid':cid,
                    'page':page
                },function(res){
						flag_one = true;
                    $("#loading").hide();
						if (res.length==0) {
							flag = false;
						}
						else{
							page++;
							var html = "";
							for(var i=0;i<res.length;i++){
								var data = res[i];
								
								
								html += '<div '+(i==0 ? '' : 'style="margin-top:10px;"')+'>' 
										 + '<font style="color:#1970fc">'+data.name+'</font> 留言于 '+data.createtime+'<br>'
										 + data.comment
										 + '</div>';
								for(var j=0;j<data.child.length;j++){
									var data_child = data.child[j];
									html += '<div style="margin-left:10px;background:#eee;border:1px solid #ddd;padding:5px">'
										 +'【'+data_child.name+'】 回复于 '+data_child.createtime+'<br>'
										 + data_child.comment
										 +'</div>';
								}
							}
						}	
						$("#comment").append(html);
                },'json');
			}
        }
	</script>

<div style="height:50px"></div>
<div class="back-fg">
	<button  onClick="javascript:window.location.href='/company/?cid={$cp.c_id}';" class="back-go">返回商户</button>
</div>

</body>
</html>